/*
 * @Author: your name
 * @Date: 2020-11-03 17:38:37
 * @LastEditTime: 2020-11-03 17:46:03
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \customer\client\js\login.js
 */
let loginInit = (function () {  
    let $userName = $(".userName"),
        $userPass = $(".userPass"),
        $submit = $(".submit");
    function handle() {
        $submit.click(function () {
            account = $userName.val().trim()
            password = $userPass.val().trim()
            if (account === "") {
                alert("请输入用户名")
                return false
            }
            if (password === "") {
                alert("请输入密码")
                return false
            }
            password = md5(password)
            axios.post("/user/login", {
                account, password
            }).then(res => {
                if (parseInt(res.code) === 0) {
                    alert("登入成功")
                    // 请求成功后
                    window.location.href = "index.html"
                    return
                }
                alert("请重新登入")
            })
        })
    };
    return {
        init() {
            handle()
        }
    };
})()
loginInit.init()